<template>
	<div class="photoinfo-container">
		<h3>{{ photoinfo.title }} </h3>
		<p class="subtitle">
			<span>发表时间{{ photoinfo.add_time }}</span>
			<span>点击：{{ photoinfo.click }}次</span>
		</p>

		<hr>
		
		<!-- 缩略图区域 -->
		<!-- :slides 是数据图片数组  -->
		<vue-preview :slides="list" @close="getThumbs"></vue-preview>


		<div class="content" v-html="photoinfo.content">
			
		</div>
		<!-- 评论子组件占的坑 -->
		<cmt-photoinfo :id="id"></cmt-photoinfo>

	</div>
</template>

<script>
	//引入子组件
	import comment from '../subcomponents/comment.vue'
	export default {
		data() {
			return {
				id: this.$route.params.id, //从路由中获取大奥的图片id 
				photoinfo: {},
				list: []
			}
		},
		created() {
			this.getPhotoInfo()
			this.getThumbs()
		},
		methods: {
			getPhotoInfo() {
				this.$http.get('api/getimageInfo/' + this.id).then(result => {
					if (result.body.status === 0) {
						this.photoinfo = result.body.message[0]
					} else {

					}
				})
			},
			getThumbs() {
				this.$http.get('api/getthumimages/' + this.id).then(result => {
					if (result.body.status === 0) {
						result.body.message.forEach(function(item) {
							item.w = 600;
							item.h = 400;
						})
						this.list = result.body.message
					} else {

					}
				})
			}

		},
		// 将子组件挂载
		components: {
			'cmt-photoinfo': comment
		}
	}
</script>

<style lang="scss" scoped>
	.photoinfo-container {
		padding: 3px;
		h3 {
			font-size: 15px;
			color: #26a2ff;
			text-align: center;
			margin: 15px 0;
		}
		.subtitle {
			font-size: 13px;
			display: flex;
			justify-content: space-between;
		}
		.content {
			font-size: 13px;
			line-height: 30px;
		}
	}
</style>